package com.yuyue.springFramework.note11.entity.springCode1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

@Component
public class UserRegisterService5 implements ApplicationEventPublisherAware {
    private ApplicationEventPublisher applicationEventPublisher;

    @Autowired
    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.applicationEventPublisher = applicationEventPublisher;
    }

    public void registerUser(String userName){
        System.out.println(String.format("[%S]用户注册成功！", userName));

        applicationEventPublisher.publishEvent(new UserRegisterEvent(this, "鱼跃"));
    }
}
